package com.elinkway.infinitemovies.bigdata;

import com.lvideo.http.bean.LVideoBaseBean;
import com.lvideo.http.bean.LVideoDataHull;

/**
 * 日常动作上报（收藏，下载，分享等）
 */
public class BigDataCommonActionTask extends BigDataBaseTask {
    /**
     * 设置acode
     *
     * @param acode {@link BigDataConstants#ACODE_CLICK},
     *              {@link BigDataConstants#ACODE_EXPOSURE},
     * @return
     */
    public BigDataCommonActionTask setAcode(String acode) {
        putParam("acode", acode);
        return this;
    }

    /**
     * 设置ap
     *
     * @param ap
     * @return
     */
    public BigDataCommonActionTask setAp(String ap) {
        putParam("ap", ap);
        return this;
    }

    /**
     * 事件结果
     *
     * @param ar {@link BigDataConstants#AR_FAILED},
     *           {@link BigDataConstants#AR_SUCCESS}
     * @return
     */
    public BigDataCommonActionTask setAR(String ar) {
        putParam("ar", ar);
        return this;
    }

    public BigDataCommonActionTask setCid(String cid) {
        putParam("cid", cid);
        return this;
    }

    public BigDataCommonActionTask setVid(String vid) {
        putParam("vid", vid);
        return this;
    }

    public BigDataCommonActionTask setPid(String pid) {
        putParam("pid", pid);
        return this;
    }

    public BigDataCommonActionTask setZid(String zid) {
        putParam("zid", zid);
        return this;
    }

    public BigDataCommonActionTask setRank(String rank) {
        putParam("rank", rank);
        return this;
    }

    public BigDataCommonActionTask setCururl(String cur_url) {
        putParam("cur_url", cur_url);
        return this;
    }

    public BigDataCommonActionTask setUuid(String uuid) {
        putParam("uuid", uuid);
        return this;
    }

    public BigDataCommonActionTask setIlu(String ilu) {
        putParam("ilu", ilu);
        return this;
    }

    /**
     * 设置网络类型
     *
     * @param netType
     * @return
     */
    public BigDataCommonActionTask setNT(String netType) {
        putParam("nt", netType);
        return this;
    }

    public BigDataCommonActionTask setReid(String reid) {
        putParam("reid", reid);
        return this;
    }

    public BigDataCommonActionTask setBucket(String bucket) {
        putParam("bucket", bucket);
        return this;
    }

    @Override
    public boolean execute() {
        LVideoDataHull<LVideoBaseBean> d = BigDataApi.postCommonAction(null, getParam("ap"), getParam("ar"),
                getParam("acode"), getParam("cid"), getParam("vid"), getParam("pid"), getParam("zid"),
                getParam("rank"), getParam("cur_url"), getParam("nt"), getParam("uuid"), getParam("ilu"), getParam("reid"), getParam("bucket"));
        return d.getDataType() == LVideoDataHull.DataType.DATA_PARSER_IS_NULL;
    }
}
